/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package elementsDefense.gui;

import com.jme3.asset.AssetManager;
import com.jme3.input.controls.ActionListener;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial.CullHint;

/**
 *
 * @author Ricardo
 */
public class PutTowerDialog {
    int screenWidth,screenHeight;
    boolean visible=false;
    Node node;
    
    Button[] buttons = new Button[3];

    public PutTowerDialog(AssetManager assetManager, Node guiNode, int screenWidth, int screenHeight) {
        int bSize = (int) (screenHeight*0.15);
        node =new Node("PutTowerDialog");
        guiNode.attachChild(node);
        
        buttons[0] = new Button(0, -20, 128, 38, "iceTower", assetManager, node);
        buttons[1] = new Button(16, 24, 128, 38, "canonTower", assetManager, node);
        buttons[2] = new Button(0, 64, 128, 38, "thunderTower", assetManager, node);
        hide();
    }

   
    public boolean testEvent(int x, int y, boolean isPressed){
        if(visible){
            for (Button button : buttons) {
                if (button.contains(x-(int)node.getLocalTranslation().x, y-(int)node.getLocalTranslation().y)) {
                    button.click();
                    return true;
                }
            }
        }
        return false;
    }
    
    
    public void show(int x, int y){
        visible=true;
        node.setCullHint(CullHint.Inherit);
        node.setLocalTranslation(x, y, 0);
    } 
    
    public void hide(){
        visible=false;
        node.setCullHint(CullHint.Always);
    }
}
